<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="下单日期" prop="dataDate">
        <el-date-picker
          clearable
          v-model="queryParams.dataDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择下单日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="品牌" prop="brandName">
        <el-input
          v-model="queryParams.brand"
          placeholder="请输入品牌"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商" prop="supplier">
        <el-input
          v-model="queryParams.supplier"
          placeholder="选择供应商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同号" prop="contractNumber">
        <el-input
          v-model="queryParams.contractNumber"
          placeholder="请输入合同号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="sku" prop="sku">
        <el-input
          v-model="queryParams.sku"
          placeholder="请输入sku"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购单号" prop="purchaseOrderNumber">
        <el-input
          v-model="queryParams.purchaseOrderNumber"
          placeholder="请输入采购单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否完结" prop="receiptStatus">
        <el-select
          v-model="queryParams.receiptStatus"
          placeholder="收货状态"
          clearable
          filterable
        >
          <el-option
            v-for="dict in receiptStatusType"
            :key="dict"
            :label="dict"
            :value="dict"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="类型" prop="contractType">
        <el-select
          v-model="queryParams.contractType"
          placeholder="请选择类型"
          clearable
          filterable
        >
          <el-option
            v-for="dict in contractTypeList"
            :key="dict"
            :label="dict"
            :value="dict"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="新品/老品" prop="isNewProduct">
          <el-input
            v-model="queryParams.isNewProduct"
            placeholder="请输入新品/老品"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="下单数量" prop="orderQuantity">
          <el-input
            v-model="queryParams.orderQuantity"
            placeholder="请输入下单数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="合同采购价" prop="contractPurchasePrice">
          <el-input
            v-model="queryParams.contractPurchasePrice"
            placeholder="请输入合同采购价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="合同采购金额" prop="contractAmount">
          <el-input
            v-model="queryParams.contractAmount"
            placeholder="请输入合同采购金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="是否含税" prop="isTaxIncluded">
          <el-input
            v-model="queryParams.isTaxIncluded"
            placeholder="请输入是否含税"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单件附加费用" prop="additionalCostPerUnit">
          <el-input
            v-model="queryParams.additionalCostPerUnit"
            placeholder="请输入单件附加费用"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="订单附加费用" prop="orderAdditionalCost">
          <el-input
            v-model="queryParams.orderAdditionalCost"
            placeholder="请输入订单附加费用"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceIncludingTax">
          <el-input
            v-model="queryParams.costPriceIncludingTax"
            placeholder="请输入成本裸价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceExcludingTax">
          <el-input
            v-model="queryParams.costPriceExcludingTax"
            placeholder="请输入成本裸价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单件税金" prop="taxAmountPerUnit">
          <el-input
            v-model="queryParams.taxAmountPerUnit"
            placeholder="请输入单件税金"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="协议到货日期" prop="contractDeliveryDate">
          <el-date-picker
            clearable
            v-model="queryParams.contractDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择协议到货日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="已入库数量" prop="quantityReceived">
          <el-input
            v-model="queryParams.quantityReceived"
            placeholder="请输入已入库数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="是否准交" prop="isOverdue30Days">
          <el-input
            v-model="queryParams.isOverdue30Days"
            placeholder="请输入是否准交"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="协议日期内已交货数量" prop="overdueQuantity30Days">
          <el-input
            v-model="queryParams.overdueQuantity30Days"
            placeholder="请输入协议日期内已交货数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="是否超入" prop="isOverOrder">
          <el-input
            v-model="queryParams.isOverOrder"
            placeholder="请输入是否超入"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="超入数量" prop="overOrderQuantity">
          <el-input
            v-model="queryParams.overOrderQuantity"
            placeholder="请输入超入数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="年" prop="dataYear">
          <el-input
            v-model="queryParams.dataYear"
            placeholder="请输入年"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="月" prop="dataMonth">
          <el-input
            v-model="queryParams.dataMonth"
            placeholder="请输入月"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8" style="display: none">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['purchase:PurchaseBasicsDwd:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['purchase:PurchaseBasicsDwd:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['purchase:PurchaseBasicsDwd:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['purchase:PurchaseBasicsDwd:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-refresh"
          size="mini"
          @click="handleRefresh"
          >同步</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="PurchaseBasicsDwdList"
      @selection-change="handleSelectionChange"
      :height="650"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!-- <el-table-column label="id" align="center" prop="id" /> -->
      <el-table-column
        fixed
        width="120"
        label="下单日期"
        align="center"
        prop="dataDate"
      ></el-table-column>
      <el-table-column fixed label="品牌" align="center" prop="brand" />
      <el-table-column fixed label="供应商" align="center" prop="supplier" />
      <el-table-column
        fixed
        width="120"
        label="合同号"
        align="center"
        prop="contractNumber"
      />
      <el-table-column
        fixed
        label="采购单号"
        align="center"
        prop="purchaseOrderNumber"
      />
      <!-- <el-table-column
        width="120"
        fixed
        label="产品款号"
        align="center"
        prop="spu"
      />
      <el-table-column fixed label="颜色" align="center" prop="colorProperty" /> -->
      <el-table-column
        width="140"
        fixed
        label="sku"
        align="center"
        prop="sku"
      />
      <!-- <el-table-column align="center" prop="firstLevelColumn" label="一级类目">
      </el-table-column>
      <el-table-column align="center" prop="secondLevelColumn" label="二级类目">
      </el-table-column>
      <el-table-column align="center" prop="threeLevelColumn" label="三级类目">
      </el-table-column>
      <el-table-column label="新品/老品" align="center" prop="isNewProduct" /> -->
      <el-table-column
        align="center"
        prop="contractType"
        label="类型"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="isNewProduct"
        label="是否新品"
      ></el-table-column>
      <el-table-column
        label="协议到货日期"
        align="center"
        prop="contractDeliveryDate"
        width="120"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.contractDeliveryDate, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>

      <el-table-column label="下单数量" align="center" prop="orderQuantity" />
      <el-table-column
        label="外部订单号"
        align="center"
        prop="externalOrderNumber"
      />
      <el-table-column label="损耗件数" align="center" prop="lossQuantity" />

      <el-table-column
        label="合同采购价(元)"
        align="center"
        prop="contractPurchasePrice"
      />
      <el-table-column
        label="合同采购金额(元)"
        align="center"
        prop="contractAmount"
      />
      <el-table-column label="是否含税" align="center" prop="isTaxIncluded" />

      <el-table-column
        label="单件附加费用(元)"
        align="center"
        prop="additionalCostPerUnit"
      />
      <el-table-column
        label="订单附加费用(元)"
        align="center"
        prop="orderAdditionalCost"
      />
      <el-table-column
        label="附加费用说明"
        align="center"
        prop="additionalCostDescription"
      >
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="bottom" width="300">
            <!-- <span>{{ scope.row.fabricComposition }}</span> -->
            <el-input
              v-model="scope.row.additionalCostDescription"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">
                {{ scope.row.additionalCostDescription }}
              </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        width="150"
        label="成本裸价(元)（含税）"
        align="center"
        prop="costPriceIncludingTax"
      />
      <el-table-column
        width="150"
        label="成本裸价(元)(不含税)"
        align="center"
        prop="costPriceExcludingTax"
      />
      <el-table-column
        label="已入库数量"
        align="center"
        prop="quantityReceived"
      />
      <el-table-column
        width="150"
        label="是否准交"
        align="center"
        prop="isOverdue30Days"
      />
      <el-table-column
        label="协议日期内已交货数量"
        align="center"
        prop="overdueQuantity30Days"
      />
      <el-table-column
        label="逾期未交付"
        align="center"
        prop="currentDelayQuantity"
      />

      <el-table-column
        label="逾期己交货数"
        align="center"
        prop="overdueDeliveryQuantity"
      />
      <el-table-column label="交付完成率 " align="center" prop="overdueRateStr">
      </el-table-column>
      <el-table-column label="收货状态" align="center" prop="receiptStatus" />
      <el-table-column label="订单状态" align="center" prop="orderStatus" />

      <el-table-column
        label="采购完结未交付数"
        align="center"
        prop="purUnDeliveryQuantity"
      />
      <el-table-column
        label="未完结待入库数量"
        align="center"
        prop="unFinishUnReceivedQuantity"
      />
      <el-table-column
        label="超入库数量"
        align="center"
        prop="overOrderReceivedQuantity"
      />
      <el-table-column
        label="是否有交货差异"
        align="center"
        prop="isOverOrder"
      />
      <el-table-column
        label="差异数量"
        align="center"
        prop="overOrderQuantity"
      />
      <!-- <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['purchase:PurchaseBasicsDwd:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['purchase:PurchaseBasicsDwd:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改采购基础对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="下单日期" prop="dataDate">
          <el-date-picker
            clearable
            v-model="form.dataDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择下单日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="品牌" prop="brandName">
          <el-input v-model="form.brandName" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="供应商" prop="supplier">
          <el-input v-model="form.supplier" placeholder="选择供应商" />
        </el-form-item>
        <el-form-item label="合同号" prop="contractNumber">
          <el-input v-model="form.contractNumber" placeholder="请输入合同号" />
        </el-form-item>
        <el-form-item label="sku" prop="sku">
          <el-input v-model="form.sku" placeholder="请输入sku" />
        </el-form-item>
        <el-form-item label="采购单号" prop="purchaseOrderNumber">
          <el-input
            v-model="form.purchaseOrderNumber"
            placeholder="请输入采购单号"
          />
        </el-form-item>
        <el-form-item label="新品/老品" prop="isNewProduct">
          <el-input v-model="form.isNewProduct" placeholder="请输入新品/老品" />
        </el-form-item>
        <el-form-item label="下单数量" prop="orderQuantity">
          <el-input v-model="form.orderQuantity" placeholder="请输入下单数量" />
        </el-form-item>
        <el-form-item label="合同采购价" prop="contractPurchasePrice">
          <el-input
            v-model="form.contractPurchasePrice"
            placeholder="请输入合同采购价"
          />
        </el-form-item>
        <el-form-item label="合同采购金额" prop="contractAmount">
          <el-input
            v-model="form.contractAmount"
            placeholder="请输入合同采购金额"
          />
        </el-form-item>
        <el-form-item label="是否含税" prop="isTaxIncluded">
          <el-input v-model="form.isTaxIncluded" placeholder="请输入是否含税" />
        </el-form-item>
        <el-form-item label="单件附加费用" prop="additionalCostPerUnit">
          <el-input
            v-model="form.additionalCostPerUnit"
            placeholder="请输入单件附加费用"
          />
        </el-form-item>
        <el-form-item label="订单附加费用" prop="orderAdditionalCost">
          <el-input
            v-model="form.orderAdditionalCost"
            placeholder="请输入订单附加费用"
          />
        </el-form-item>
        <el-form-item label="附加费用说明" prop="additionalCostDescription">
          <el-input
            v-model="form.additionalCostDescription"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceIncludingTax">
          <el-input
            v-model="form.costPriceIncludingTax"
            placeholder="请输入成本裸价"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceExcludingTax">
          <el-input
            v-model="form.costPriceExcludingTax"
            placeholder="请输入成本裸价"
          />
        </el-form-item>
        <el-form-item label="单件税金" prop="taxAmountPerUnit">
          <el-input
            v-model="form.taxAmountPerUnit"
            placeholder="请输入单件税金"
          />
        </el-form-item>
        <el-form-item label="协议到货日期" prop="contractDeliveryDate">
          <el-date-picker
            clearable
            v-model="form.contractDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择协议到货日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="已入库数量" prop="quantityReceived">
          <el-input
            v-model="form.quantityReceived"
            placeholder="请输入已入库数量"
          />
        </el-form-item>
        <el-form-item label="是否准交" prop="isOverdue30Days">
          <el-input
            v-model="form.isOverdue30Days"
            placeholder="请输入是否准交"
          />
        </el-form-item>
        <el-form-item label="协议日期内已交货数量" prop="overdueQuantity30Days">
          <el-input
            v-model="form.overdueQuantity30Days"
            placeholder="请输入协议日期内已交货数量"
          />
        </el-form-item>
        <el-form-item label="是否超入" prop="isOverOrder">
          <el-input v-model="form.isOverOrder" placeholder="请输入是否超入" />
        </el-form-item>
        <el-form-item label="超入数量" prop="overOrderQuantity">
          <el-input
            v-model="form.overOrderQuantity"
            placeholder="请输入超入数量"
          />
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input
            v-model="form.remarks"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="年" prop="dataYear">
          <el-input v-model="form.dataYear" placeholder="请输入年" />
        </el-form-item>
        <el-form-item label="月" prop="dataMonth">
          <el-input v-model="form.dataMonth" placeholder="请输入月" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPurchaseBasicsDwd,
  getPurchaseBasicsDwd,
  delPurchaseBasicsDwd,
  addPurchaseBasicsDwd,
  updatePurchaseBasicsDwd,
  synData,
} from "@/api/purchase/PurchaseBasicsDwd";

export default {
  name: "PurchaseBasicsDwd",
  props: {
    query: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      contractTypeList: ["产品", "配件", "返修品"],
      receiptStatusType: ["未入库", "部分入库", "全部入库"],
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 采购基础表格数据
      PurchaseBasicsDwdList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        dataDate: null,
        brandName: null,
        supplier: null,
        contractNumber: null,
        sku: null,
        purchaseOrderNumber: null,
        isNewProduct: null,
        orderQuantity: null,
        contractPurchasePrice: null,
        contractAmount: null,
        isTaxIncluded: null,
        additionalCostPerUnit: null,
        orderAdditionalCost: null,
        additionalCostDescription: null,
        costPriceIncludingTax: null,
        costPriceExcludingTax: null,
        taxAmountPerUnit: null,
        contractDeliveryDate: null,
        quantityReceived: null,
        isOverdue30Days: null,
        overdueQuantity30Days: null,
        isOverOrder: null,
        overOrderQuantity: null,
        remarks: null,
        dataYear: null,
        dataMonth: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        brandName: [
          { required: true, message: "品牌不能为空", trigger: "blur" },
        ],
        supplier: [
          { required: true, message: "供应商不能为空", trigger: "blur" },
        ],
        contractNumber: [
          { required: true, message: "合同号不能为空", trigger: "blur" },
        ],
        sku: [{ required: true, message: "sku不能为空", trigger: "blur" }],
        purchaseOrderNumber: [
          { required: true, message: "采购单号不能为空", trigger: "blur" },
        ],
        isNewProduct: [
          { required: true, message: "新品/老品不能为空", trigger: "blur" },
        ],
        orderQuantity: [
          { required: true, message: "下单数量不能为空", trigger: "blur" },
        ],
        contractPurchasePrice: [
          { required: true, message: "合同采购价不能为空", trigger: "blur" },
        ],
        contractAmount: [
          { required: true, message: "合同采购金额不能为空", trigger: "blur" },
        ],
        isTaxIncluded: [
          { required: true, message: "是否含税不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.queryParams = this.query;
    this.getList();
  },
  methods: {
    // 打开加载层
    openLoading() {
      this.$modal.loading("正在加载数据，请稍候！");
    },
    /** 刷新缓存按钮操作 Warning*/
    handleRefresh() {
      // this.$modal.msgWarning("数据正在同步，请稍候");

      // const obj = {
      //   startTime: this.timeGap.startTime,
      //   endTime: this.timeGap.endTime,
      // };
      this.openLoading();
      synData().then(() => {
        // this.$modal.msgSuccess("同步数据成功");
        this.$modal.closeLoading();
        this.getList();
        // this.$store.dispatch('dict/cleanDict');
      });
    },
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询采购基础列表 */
    getList() {
      this.loading = true;
      listPurchaseBasicsDwd(this.queryParams).then((response) => {
        this.PurchaseBasicsDwdList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        dataDate: null,
        brandName: null,
        supplier: null,
        contractNumber: null,
        sku: null,
        purchaseOrderNumber: null,
        isNewProduct: null,
        orderQuantity: null,
        contractPurchasePrice: null,
        contractAmount: null,
        isTaxIncluded: null,
        additionalCostPerUnit: null,
        orderAdditionalCost: null,
        additionalCostDescription: null,
        costPriceIncludingTax: null,
        costPriceExcludingTax: null,
        taxAmountPerUnit: null,
        contractDeliveryDate: null,
        quantityReceived: null,
        isOverdue30Days: null,
        overdueQuantity30Days: null,
        isOverOrder: null,
        overOrderQuantity: null,
        remarks: null,
        dataYear: null,
        dataMonth: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {};
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加采购基础";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPurchaseBasicsDwd(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改采购基础";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updatePurchaseBasicsDwd(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPurchaseBasicsDwd(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除采购基础编号为"' + ids + '"的数据项？')
        .then(function () {
          return delPurchaseBasicsDwd(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      delete this.queryParams.pageNum;
      delete this.queryParams.pageSize;
      this.download(
        "purchase/PurchaseBasicsDwd/export",
        {
          ...this.queryParams,
        },
        `PurchaseBasicsDwd_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  height: 80vh;
  overflow-x: hidden;
}

.el-input.is-disabled ::v-deep .el-input__inner {
  color: #606266;
  background-color: white;
  border: none;
}

.el-textarea.is-disabled ::v-deep .el-textarea__inner {
  color: #606266;
  background-color: white;
  border: none;
  width: 500px;
  resize: none;
  cursor: pointer;
}

span.textname {
  display: -webkit-box;

  text-overflow: ellipsis;
  overflow: hidden;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}
</style>